package com.shijie.newvideo;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;

public class ImageLoad {

    public final static int imgCorner15 = 15;
    public final static int imgCorner5 = 5; // 修改为5
    public final static int imgCorner6 = 6;
    public final static int imgCorner_large = 8;

    private static final int DEFAULT_PLACEHOLDER = R.drawable.zhuanti_shadow_bg;

    public static void loadCicleRadiusImage(Context context, ImageView imageView, String url) {
        loadCicleRadiusImage(context, imageView, url, DEFAULT_PLACEHOLDER, imgCorner_large, ImageView.ScaleType.CENTER_CROP);
    }

    public static void loadCicleRadiusImage(Context context, ImageView imageView, String url, int placeholder) {
        loadCicleRadiusImage(context, imageView, url, placeholder, imgCorner_large, ImageView.ScaleType.CENTER_CROP);
    }

    public static void loadCicleRadiusImage(Context context, ImageView imageView, String url, int placeholder, int cornerRadius, ImageView.ScaleType scaleType) {
        RequestOptions requestOptions = new RequestOptions()
                .placeholder(placeholder)
                .error(placeholder)
                .transform(new CenterCrop(), new RoundedCorners(cornerRadius));
        imageView.setScaleType(scaleType);
        Glide.with(context)
                .load(url)
                .apply(requestOptions)  // 应用请求选项
                .into(imageView);       // 加载到目标 ImageView
    }
}

